//
//  DetailTitleTableViewCell.m
//  Fangmm
//
//  Created by 阮琦 on 16/3/1.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "DetailTitleTableViewCell.h"

@implementation DetailTitleTableViewCell {

    __weak IBOutlet UIImageView *landlordImageView;
    __weak IBOutlet UIImageView *checkImageView;
    __weak IBOutlet UILabel *landlordLabel;
    __weak IBOutlet UILabel *checkLabel;
    int numberOfLine;
}

- (void)awakeFromNib {
    // Initialization code
    if (self.isLandlordLeading) {
        landlordImageView.hidden = false;
        landlordLabel.hidden = false;
    } else {
        landlordImageView.hidden = true;
        landlordLabel.hidden = true;
    }
    if (self.isChecked) {
        checkImageView.hidden = false;
        checkLabel.hidden = false;
    } else {
        checkImageView.hidden = true;
        checkLabel.hidden = true;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (int)calculateNumberOfLine {
    NSString *string = self.houseDescriptionLabel.text;
    CGSize size =[string sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]}];
    CGSize descriptionSize = [self.houseDescriptionLabel.text boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} context:nil].size;
    numberOfLine = ceil(descriptionSize.height / size.height);
    if (numberOfLine >= 2) {
        self.foldButton.hidden = false;
    } else {
        self.foldButton.hidden = true;
    }
    return numberOfLine;
}

- (IBAction)clickToFoldorOpen:(UIButton *)sender {
    [self.delegate openOrFoldCellWithStatus:self.isOpen];
}

@end
